package com.demo.project_template.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.demo.project_template.entity.ProductAttributeKey;
import com.demo.project_template.entity.ProductAttributeValue;
import com.demo.project_template.mapper.ProductAttributeKeyMapper;
import com.demo.project_template.mapper.ProductAttributeValueMapper;
import com.demo.project_template.service.ProductAttributeValueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 属性value表 服务实现类
 * </p>
 *
 * @author 杨玉龙
 * @since 2023-06-19 15:56:44
 */
@Service
public class ProductAttributeValueServiceImpl extends ServiceImpl<ProductAttributeValueMapper, ProductAttributeValue> implements ProductAttributeValueService {
    @Resource
    private ProductAttributeKeyMapper productAttributeKeyMapper;

//    @Override
//    public List<ProductAttributeKey> selectAttributeKeyAndValueByProductId(Integer productId) {
//        List<ProductAttributeKey> productAttributeKeys = productAttributeKeyMapper.selectList(new LambdaQueryWrapper<ProductAttributeKey>().eq(ProductAttributeKey::getProductId, productId));
//        for (ProductAttributeKey productAttributeKey : productAttributeKeys) {
//            List<ProductAttributeValue> productAttributeValues = list(new LambdaQueryWrapper<ProductAttributeValue>().eq(ProductAttributeValue::getAttributeKeyId, productAttributeKey.getAttributeKeyId()).orderByDesc(ProductAttributeValue::getUpdateTime));
//            productAttributeKey.setProductAttributeValues(productAttributeValues);
//        }
//        return productAttributeKeys;
//    }
}
